package multi;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.UUID;

public class TestMain {

	public static void main(String[] args) {
				
		//logParamsUsed();
		
		ThreadGroup groupA = new ThreadGroup("Group A"); 
		List threads = new ArrayList();   

		long startTime =  Calendar.getInstance().getTimeInMillis() ;
		
		Runnable multiTest;
		//Start Threads
		for (int i=0; i<Constants.NO_OF_THREADS; i++)	
		{
			if (Constants.TEST_TO_RUN == Constants.TEST_TYPE_MYSQL)
				multiTest = new SpatialMultiTest();
			else if (Constants.TEST_TO_RUN == Constants.TEST_TYPE_PG)
				multiTest = new SpatialMultiTestPG();
			else if (Constants.TEST_TO_RUN == Constants.TEST_TYPE_MONGO)
				multiTest = new SpatialMultiTestMongo();
			
			Thread t = new Thread( groupA, multiTest);
			t.start();
			threads.add(t);			
 		}
		
		//We will provision to wait for threads to complete
		try
		{
			for (int i = 0; i < threads.size(); i++)   
			      ((Thread) threads.get(i)).join();  
			
			//All threads done at this point.
			long timeTaken = 	Calendar.getInstance().getTimeInMillis() - startTime;
			System.out.println("Average Time: " + Constants.totaltimetaken/Constants.NO_OF_THREADS);
			System.out.println("Total Time Taken: " + timeTaken + " milliseconds to complete.");
		}
		catch(InterruptedException e)
		{
			e.printStackTrace();
		}				
	}		

}
